bench command supports --no-fail-fast flag.
authorEvgen Druzhynin <evgen.druzhynin@gmail.com>
Tue, 4 Jul 2017 16:48:28 +0000 (19:48 +0300)
committerEvgen Druzhynin <evgen.druzhynin@gmail.com>
Tue, 4 Jul 2017 16:48:28 +0000 (19:48 +0300)
src/bin/bench.rs
tests/bench.rs

index 9e34f7847258eb4cd36d694e0808d3fbaee8fd16..ff1e0b4e7baee1ec58f36b0eed067753cd6d9165 100644 (file)
@@ -26,6 +26,7 @@ pub struct Options {
     flag_tests: bool,
     flag_bench: Vec<String>,
     flag_benches: bool,
+    flag_no_fail_fast: bool,
     flag_frozen: bool,
     flag_locked: bool,
     arg_args: Vec<String>,
@@ -64,6 +65,7 @@ Options:
     -q, --quiet                  No output printed to stdout
     --color WHEN                 Coloring: auto, always, never
     --message-format FMT         Error format: human, json [default: human]
+    --no-fail-fast               Run all benchmarks regardless of failure
     --frozen                     Require Cargo.lock and cache are up to date
     --locked                     Require Cargo.lock is up to date
 
@@ -99,7 +101,7 @@ pub fn execute(options: Options, config: &Config) -> CliResult {
                      options.flag_locked)?;
     let ops = ops::TestOptions {
         no_run: options.flag_no_run,
-        no_fail_fast: false,
+        no_fail_fast: options.flag_no_fail_fast,
         only_doc: false,
         compile_opts: ops::CompileOptions {
             config: config,
index 6a49632ee14f6772e4a02299e980d06590a7168e..b9adbf46693ac09bbae09c68342cfa4a0666a534 100644 (file)
@@ -879,6 +879,44 @@ fn test_bench_no_run() {
 "));
 }
 
+#[test]
+fn test_bench_no_fail_fast() {
+    if !is_nightly() { return }
+
+    let p = project("foo")
+        .file("Cargo.toml", &basic_bin_manifest("foo"))
+        .file("src/foo.rs", r#"
+            #![feature(test)]
+            extern crate test;
+            fn hello() -> &'static str {
+                "hello"
+            }
+
+            pub fn main() {
+                println!("{}", hello())
+            }
+
+            #[bench]
+            fn bench_hello(_b: &mut test::Bencher) {
+                assert_eq!(hello(), "hello")
+            }
+
+            #[bench]
+            fn bench_nope(_b: &mut test::Bencher) {
+                assert_eq!("nope", hello())
+            }"#);
+
+    assert_that(p.cargo_process("bench").arg("--no-fail-fast"),
+                execs().with_status(101)
+                    .with_stderr_contains("\
+[RUNNING] target[/]release[/]deps[/]foo-[..][EXE]")
+                    .with_stdout_contains("running 2 tests")
+                    .with_stderr_contains("\
+[RUNNING] target[/]release[/]deps[/]foo-[..][EXE]")
+                    .with_stdout_contains("test bench_hello [..]")
+                    .with_stdout_contains("test bench_nope [..]"));
+}
+
 #[test]
 fn test_bench_multiple_packages() {
     if !is_nightly() { return }